package com.uusee.shipshape.zq.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Type;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.uusee.framework.bo.UniversalBo;
import com.uusee.shipshape.gt.model.SourceSite;

@Entity
@Table(name = "ss_zq_video_reg")
@SuppressWarnings("serial")
public class VideoReg implements Serializable {
	@Id
	@Column(name = "page_code")
	private String pageCode;

	@ManyToOne
	@JoinColumn(name = "source_site")
	private SourceSite sourceSite = new SourceSite();
	
	@Column(name = "page_name")
	private String pageName;

	@Column(name = "page_encoder")
	private String pageEncoder;
	
	@Column(name = "page_must_tag")
	private String pageMustTag;

	@Column(name = "page_front_filter_reg")
	@Type(type = "org.springframework.orm.hibernate3.support.ClobStringType")
	private String pageFrontFilterReg;

	@Column(name = "page_back_filter_reg")
	@Type(type = "org.springframework.orm.hibernate3.support.ClobStringType")
	private String pageBackFilterReg;
	
	@Column(name = "video_count_reg")
	@Type(type = "org.springframework.orm.hibernate3.support.ClobStringType")
	private String videoCountReg;
	
	@Column(name = "video_page_count_reg")
	@Type(type = "org.springframework.orm.hibernate3.support.ClobStringType")
	private String videoPageCountReg;
	
	@Column(name = "video_list_reg")
	@Type(type = "org.springframework.orm.hibernate3.support.ClobStringType")
	private String videoListReg;

	@Column(name = "video_reg")
	@Type(type = "org.springframework.orm.hibernate3.support.ClobStringType")
	private String videoReg;
	
	@Column(name = "video_id_1_reg")
	@Type(type = "org.springframework.orm.hibernate3.support.ClobStringType")
	private String videoId1Reg;
	
	@Column(name = "video_id_2_reg")
	@Type(type = "org.springframework.orm.hibernate3.support.ClobStringType")
	private String videoId2Reg;
	
	@Column(name = "original_title_reg")
	@Type(type = "org.springframework.orm.hibernate3.support.ClobStringType")
	private String originalTitleReg;

	@Column(name = "logo_reg")
	@Type(type = "org.springframework.orm.hibernate3.support.ClobStringType")
	private String logoReg;

	@Column(name = "length_reg")
	@Type(type = "org.springframework.orm.hibernate3.support.ClobStringType")
	private String lengthReg;
	
	@Column(name = "category_reg")
	@Type(type = "org.springframework.orm.hibernate3.support.ClobStringType")
	private String categoryReg;
	
	@Column(name = "quality_reg")
	@Type(type = "org.springframework.orm.hibernate3.support.ClobStringType")
	private String qualityReg;
	
	@Column(name = "play_url_reg")
	@Type(type = "org.springframework.orm.hibernate3.support.ClobStringType")
	private String playUrlReg;

	@Column(name = "share_url_reg")
	@Type(type = "org.springframework.orm.hibernate3.support.ClobStringType")
	private String shareUrlReg;

	@Column(name = "object_code_reg")
	@Type(type = "org.springframework.orm.hibernate3.support.ClobStringType")
	private String objectCodeReg;
	
	@Column(name = "summary_reg")
	@Type(type = "org.springframework.orm.hibernate3.support.ClobStringType")
	private String summaryReg;
	
	@Column(name = "tags_reg")
	@Type(type = "org.springframework.orm.hibernate3.support.ClobStringType")
	private String tagsReg;
	
	@Column(name = "upload_user_id_reg")
	@Type(type = "org.springframework.orm.hibernate3.support.ClobStringType")
	private String uploadUserIdReg;
	
	@Column(name = "upload_username_reg")
	@Type(type = "org.springframework.orm.hibernate3.support.ClobStringType")
	private String uploadUsernameReg;
	
	@Column(name = "upload_user_blog_url_reg")
	@Type(type = "org.springframework.orm.hibernate3.support.ClobStringType")
	private String uploadUserBlogUrlReg;
	
	@Column(name = "upload_date_reg")
	@Type(type = "org.springframework.orm.hibernate3.support.ClobStringType")
	private String uploadDateReg;

	@Column(name = "play_times_reg")
	@Type(type = "org.springframework.orm.hibernate3.support.ClobStringType")
	private String playTimesReg;
	
	@Column(name = "update_user")
	private String updateUser;

	@Column(name = "update_date")
	private Date updateDate;

	public SourceSite getSourceSite() {
		return sourceSite;
	}

	public void setSourceSite(SourceSite sourceSite) {
		this.sourceSite = sourceSite;
	}

	public String getPageCode() {
		return pageCode;
	}

	public void setPageCode(String pageCode) {
		this.pageCode = pageCode;
	}

	public String getPageName() {
		return pageName;
	}

	public void setPageName(String pageName) {
		this.pageName = pageName;
	}

	public String getPageEncoder() {
		return pageEncoder;
	}

	public void setPageEncoder(String pageEncoder) {
		this.pageEncoder = pageEncoder;
	}

	public String getPageMustTag() {
		return pageMustTag;
	}

	public void setPageMustTag(String pageMustTag) {
		this.pageMustTag = pageMustTag;
	}

	public String getPageFrontFilterReg() {
		return pageFrontFilterReg;
	}

	public void setPageFrontFilterReg(String pageFrontFilterReg) {
		this.pageFrontFilterReg = pageFrontFilterReg;
	}

	public String getPageBackFilterReg() {
		return pageBackFilterReg;
	}

	public void setPageBackFilterReg(String pageBackFilterReg) {
		this.pageBackFilterReg = pageBackFilterReg;
	}
	
	public String getVideoCountReg() {
		return videoCountReg;
	}

	public void setVideoCountReg(String videoCountReg) {
		this.videoCountReg = videoCountReg;
	}

	public String getVideoPageCountReg() {
		return videoPageCountReg;
	}

	public void setVideoPageCountReg(String videoPageCountReg) {
		this.videoPageCountReg = videoPageCountReg;
	}

	public String getVideoListReg() {
		return videoListReg;
	}

	public void setVideoListReg(String videoListReg) {
		this.videoListReg = videoListReg;
	}

	public String getVideoReg() {
		return videoReg;
	}

	public void setVideoReg(String videoReg) {
		this.videoReg = videoReg;
	}

	public String getVideoId1Reg() {
		return videoId1Reg;
	}

	public void setVideoId1Reg(String videoId1Reg) {
		this.videoId1Reg = videoId1Reg;
	}

	public String getVideoId2Reg() {
		return videoId2Reg;
	}

	public void setVideoId2Reg(String videoId2Reg) {
		this.videoId2Reg = videoId2Reg;
	}

	public String getOriginalTitleReg() {
		return originalTitleReg;
	}

	public void setOriginalTitleReg(String originalTitleReg) {
		this.originalTitleReg = originalTitleReg;
	}

	public String getLogoReg() {
		return logoReg;
	}

	public void setLogoReg(String logoReg) {
		this.logoReg = logoReg;
	}

	public String getLengthReg() {
		return lengthReg;
	}

	public void setLengthReg(String lengthReg) {
		this.lengthReg = lengthReg;
	}

	public String getCategoryReg() {
		return categoryReg;
	}

	public void setCategoryReg(String categoryReg) {
		this.categoryReg = categoryReg;
	}

	public String getQualityReg() {
		return qualityReg;
	}

	public void setQualityReg(String qualityReg) {
		this.qualityReg = qualityReg;
	}

	public String getPlayUrlReg() {
		return playUrlReg;
	}

	public void setPlayUrlReg(String playUrlReg) {
		this.playUrlReg = playUrlReg;
	}

	public String getShareUrlReg() {
		return shareUrlReg;
	}

	public void setShareUrlReg(String shareUrlReg) {
		this.shareUrlReg = shareUrlReg;
	}

	public String getObjectCodeReg() {
		return objectCodeReg;
	}

	public void setObjectCodeReg(String objectCodeReg) {
		this.objectCodeReg = objectCodeReg;
	}

	public String getSummaryReg() {
		return summaryReg;
	}

	public void setSummaryReg(String summaryReg) {
		this.summaryReg = summaryReg;
	}

	public String getTagsReg() {
		return tagsReg;
	}

	public void setTagsReg(String tagsReg) {
		this.tagsReg = tagsReg;
	}

	public String getUploadUserIdReg() {
		return uploadUserIdReg;
	}

	public void setUploadUserIdReg(String uploadUserIdReg) {
		this.uploadUserIdReg = uploadUserIdReg;
	}

	public String getUploadUsernameReg() {
		return uploadUsernameReg;
	}

	public void setUploadUsernameReg(String uploadUsernameReg) {
		this.uploadUsernameReg = uploadUsernameReg;
	}

	public String getUploadUserBlogUrlReg() {
		return uploadUserBlogUrlReg;
	}

	public void setUploadUserBlogUrlReg(String uploadUserBlogUrlReg) {
		this.uploadUserBlogUrlReg = uploadUserBlogUrlReg;
	}

	public String getUploadDateReg() {
		return uploadDateReg;
	}

	public void setUploadDateReg(String uploadDateReg) {
		this.uploadDateReg = uploadDateReg;
	}

	public String getPlayTimesReg() {
		return playTimesReg;
	}

	public void setPlayTimesReg(String playTimesReg) {
		this.playTimesReg = playTimesReg;
	}

	public String getUpdateUser() {
		return updateUser;
	}

	public void setUpdateUser(String updateUser) {
		this.updateUser = updateUser;
	}

	public Date getUpdateDate() {
		return updateDate;
	}

	public void setUpdateDate(Date updateDate) {
		this.updateDate = updateDate;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((pageCode == null) ? 0 : pageCode.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		VideoReg other = (VideoReg) obj;
		if (pageCode == null) {
			if (other.pageCode != null)
				return false;
		} else if (!pageCode.equals(other.pageCode))
			return false;
		return true;
	}

	public static VideoReg getYoukuCategoryVideoReg(SourceSite youku) {
		VideoReg queryVideoReg = new VideoReg();
		queryVideoReg.setSourceSite(youku);
		queryVideoReg.setPageCode("YOUKU_CATEGORY_VIDEO_LIST");
		queryVideoReg.setPageName("优酷分类视频列表页");
		queryVideoReg.setPageEncoder("UTF-8");
		queryVideoReg.setPageMustTag("");
		queryVideoReg.setPageFrontFilterReg(".*<div id=\"list\">");
		queryVideoReg.setPageBackFilterReg("<div class=\"LPageBar\">.*");
		queryVideoReg.setVideoCountReg("");
		queryVideoReg.setVideoPageCountReg("");
		queryVideoReg.setVideoListReg("<div class=\"videos\">(.*?)</div><!--videos end-->");
		queryVideoReg.setVideoReg("<ul class=\"video\">(.*?)</ul>");
		queryVideoReg.setVideoId1Reg("<li><h1><a href=\"http://v.youku.com/v_show/id_(.*?).html\".*?>.*?</a>.*?</h1></li>");
		queryVideoReg.setVideoId2Reg("");
		queryVideoReg.setOriginalTitleReg("<li><h1><a.*?title=\"(.*?)\".*?>.*?</a>.*?</h1></li>");
		queryVideoReg.setLogoReg("<li class=\"videoImg\">.*?<a.*?><img src=\"(.*?)\".*?/>.*?</a>.*?</li>");
		queryVideoReg.setLengthReg("<li><h1><a.*?>.*?</a>.*?<span class=\"num\">(.*?)</span></h1></li>");
		queryVideoReg.setQualityReg("");
		queryVideoReg.setCategoryReg("");
		queryVideoReg.setTagsReg("");
		queryVideoReg.setSummaryReg("");
		queryVideoReg.setShareUrlReg("http://player.youku.com/player.php/sid/::VIDEOID1/v.swf");
		queryVideoReg.setObjectCodeReg("<embed src=\"::SHAREURL\" quality=\"high\" width=\"480\" height=\"400\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\"></embed>");
		queryVideoReg.setPlayTimesReg("<li>播放: <span class=\"num\">([0-9,]*?)</span>.*?</li>");
		queryVideoReg.setPlayUrlReg("<li><h1><a href=\"(.*?)\".*?>.*?</a>.*?</h1></li>");
		queryVideoReg.setUploadDateReg("<li class=\"vUser\"><a.*?>.*?</a>.*?<span class=\"post\">(.*?)</span></li>");
		queryVideoReg.setUploadUserIdReg("<li class=\"vUser\">.*?<a href=\"http://u.youku.com/user_show/id_(.*?)\\.html\".*?>.*?</a>.*?</li>");
		queryVideoReg.setUploadUsernameReg("<li class=\"vUser\">.*?<a.*?>(.*?)</a>.*?</li>");
		queryVideoReg.setUploadUserBlogUrlReg("<li class=\"vUser\">.*?<a href=\"(.*?)\".*?>.*?</a>.*?</li>");
		queryVideoReg.setUpdateUser("wangrui");
		queryVideoReg.setUpdateDate(new Date());
		
		return queryVideoReg;
	}
	
	public static VideoReg getYoukuQueryPageVideoReg(SourceSite youku) {
		VideoReg queryVideoReg = new VideoReg();
		queryVideoReg.setSourceSite(youku);
		queryVideoReg.setPageCode("youku_query_video_result");
		queryVideoReg.setPageName("优酷搜索视频结果页");
		queryVideoReg.setPageEncoder("UTF-8");
		queryVideoReg.setPageMustTag("<div class=\"searchResult\">");
		queryVideoReg.setPageFrontFilterReg(".*<div class=\"searchResult\">");
		queryVideoReg.setPageBackFilterReg("<div class=\"LPageBar\">.*");
		queryVideoReg.setVideoCountReg("");
		queryVideoReg.setVideoPageCountReg("");
		queryVideoReg.setVideoListReg("<div class=\"videos\">(.*?)</div><!--videos end-->");
		queryVideoReg.setVideoReg("<ul class=\"video\">(.*?)</ul>");
		queryVideoReg.setVideoId1Reg("<li><h1><a href=\"http://v.youku.com/v_show/id_(.*?).html\".*?>.*?</a>.*?</h1></li>");
		queryVideoReg.setVideoId2Reg("");
		queryVideoReg.setOriginalTitleReg("<li><h1><a.*?title=\"(.*?)\".*?>.*?</a>.*?</h1></li>");
		queryVideoReg.setLogoReg("<li class=\"videoImg\">.*?<a.*?><img src=\"(.*?)\".*?/>.*?</a>.*?</li>");
		queryVideoReg.setLengthReg("<li><h1><a.*?>.*?</a>.*?<span class=\"num\">(.*?)</span></h1></li>");
		queryVideoReg.setQualityReg("");
		queryVideoReg.setCategoryReg("");
		queryVideoReg.setTagsReg("");
		queryVideoReg.setSummaryReg("");
		queryVideoReg.setShareUrlReg("http://player.youku.com/player.php/sid/::VIDEOID1/v.swf");
		queryVideoReg.setObjectCodeReg("<embed src=\"::SHAREURL\" quality=\"high\" width=\"480\" height=\"400\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\"></embed>");
		queryVideoReg.setPlayTimesReg("<li>播放: <span class=\"num\">([0-9,]*?)</span>.*?</li>");
		queryVideoReg.setPlayUrlReg("<li><h1><a href=\"(.*?)\".*?>.*?</a>.*?</h1></li>");
		queryVideoReg.setUploadDateReg("<li class=\"vUser\"><a.*?>.*?</a>.*?<span class=\"post\">(.*?)</span></li>");
		queryVideoReg.setUploadUserIdReg("<li class=\"vUser\">.*?<a href=\"http://u.youku.com/user_show/id_(.*?)\\.html\".*?>.*?</a>.*?</li>");
		queryVideoReg.setUploadUsernameReg("<li class=\"vUser\">.*?<a.*?>(.*?)</a>.*?</li>");
		queryVideoReg.setUploadUserBlogUrlReg("<li class=\"vUser\">.*?<a href=\"(.*?)\".*?>.*?</a>.*?</li>");
		queryVideoReg.setUpdateUser("wangrui");
		queryVideoReg.setUpdateDate(new Date());
		
		return queryVideoReg;
	}
	
	public static VideoReg getKuliuQueryPageVideoReg(SourceSite kuliu) {
		VideoReg queryVideoReg = new VideoReg();
		queryVideoReg.setSourceSite(kuliu);
		queryVideoReg.setPageCode("ku6_query_video_result");
		queryVideoReg.setPageName("酷6搜索视频结果页");
		queryVideoReg.setPageEncoder("GBK");
		queryVideoReg.setPageMustTag("");
		queryVideoReg.setPageFrontFilterReg(".*<div id=\"img\"  style=\"display:none\">");
		queryVideoReg.setPageBackFilterReg("<div class=\"box relative clearfix\">.*");
		queryVideoReg.setVideoCountReg("");
		queryVideoReg.setVideoPageCountReg("");
		queryVideoReg.setVideoListReg("<div class=\"list clearfix\" >(.*?)<div class=\"page\">");
		queryVideoReg.setVideoReg("<dl>(.*?)</dl>");
		queryVideoReg.setVideoId1Reg("<dt><span><a href=\"http://v.ku6.com/show/(.*?)\\.html\".*?><img.*?/></a></span>.*?</dt>");
		queryVideoReg.setVideoId2Reg("");
		queryVideoReg.setOriginalTitleReg("<dt><span><a.*?title=\"(.*?)\"><img.*?/></a></span>.*?</dt>");
		queryVideoReg.setLogoReg("<dt><span><a.*?><img src=\"(.*?)\".*?/></a></span>.*?</dt>");
		queryVideoReg.setLengthReg("<dt>.*?<span class=\"time\">(.*?)</span></dt>");
		queryVideoReg.setQualityReg("");
		queryVideoReg.setCategoryReg("");
		queryVideoReg.setTagsReg("");
		queryVideoReg.setSummaryReg("");
		queryVideoReg.setShareUrlReg("http://player.ku6.com/refer/::VIDEOID1/v.swf");
		queryVideoReg.setObjectCodeReg("<embed src=\"::SHAREURL\" quality=\"high\" width=\"414\" height=\"305\" align=\"middle\" allowScriptAccess=\"always\" type=\"application/x-shockwave-flash\"></embed>");
		queryVideoReg.setPlayTimesReg("<dd>播放.*?<span>(.*?)</span></a></dd>");
		queryVideoReg.setPlayUrlReg("<dt><span><a href=\"(.*?)\".*?><img.*?/></a></span>.*?</dt>");
		queryVideoReg.setUploadDateReg("<dd>发布：(.*?)</dd>");
		queryVideoReg.setUploadUserIdReg("<dd>播客：<a href=\"http://v.ku6.com/(.*?)\".*?>.*?</a></dd>");
		queryVideoReg.setUploadUsernameReg("<dd>播客：<a.*?title=\"(.*?)\".*?>.*?</a></dd>");
		queryVideoReg.setUploadUserBlogUrlReg("<dd>播客：<a href=\"(.*?)\".*?>.*?</a></dd>");
		queryVideoReg.setUpdateUser("wangrui");
		queryVideoReg.setUpdateDate(new Date());
		
		return queryVideoReg;
	}
	
	public static VideoReg getSinaQueryPageVideoReg(SourceSite sina) {
		VideoReg sinaVideoQueryVideoReg = new VideoReg();
		sinaVideoQueryVideoReg.setSourceSite(sina);
		sinaVideoQueryVideoReg.setPageCode("sina_query_video_result");
		sinaVideoQueryVideoReg.setPageName("新浪搜索视频结果页");
		sinaVideoQueryVideoReg.setPageEncoder("gb2312");
		sinaVideoQueryVideoReg.setPageMustTag("<div class=\"sear_list\">");
		sinaVideoQueryVideoReg.setPageFrontFilterReg("");
		sinaVideoQueryVideoReg.setPageBackFilterReg("<div class=\"sear_right\">.*");
		sinaVideoQueryVideoReg.setVideoPageCountReg("");
		sinaVideoQueryVideoReg.setVideoListReg("<div class=\"sear_menu\">(.*?)<li class=\"pagenum\">");
		sinaVideoQueryVideoReg.setVideoReg("<div class=\"sear_list\">.*?<ul>(.*?)</ul>.*?</div>");

		sinaVideoQueryVideoReg.setVideoId1Reg("<li class=\"bk1\"><a href=\"http://you.video.sina.com.cn/b/(.*?)\\.html\".*?><img.*?>.*?</li>");
		sinaVideoQueryVideoReg.setVideoId2Reg("<li class=\"bk1\"><a href=\"http://you.video.sina.com.cn/b/([0-9]+)\\-[0-9]+\\.html\".*?><img.*?/></a></li>");
		sinaVideoQueryVideoReg.setOriginalTitleReg("<li class=\"tit1\"><a.*?>(.*?)</a></li>");
		sinaVideoQueryVideoReg.setLogoReg("<li class=\"bk1\">.*?<img src=\"(.*?)\".*?/>.*?</li>");
		sinaVideoQueryVideoReg.setLengthReg("<td width=\"43%\">时长：(.*?)</td>");
		sinaVideoQueryVideoReg.setCategoryReg("");
		sinaVideoQueryVideoReg.setTagsReg("");
		sinaVideoQueryVideoReg.setSummaryReg("");
		sinaVideoQueryVideoReg.setShareUrlReg("http://vhead.blog.sina.com.cn/player/outer_player.swf?auto=1&vid=::VIDEOID2&uid=::UPLOADUSERID");
		sinaVideoQueryVideoReg.setObjectCodeReg("<object id=\"ssss\" width=\"480\" height=\"370\" ><param name=\"allowScriptAccess\" value=\"always\" /><embed pluginspage=\"http://www.macromedia.com/go/getflashplayer\" src=\"::SHAREURL\" type=\"application/x-shockwave-flash\" name=\"ssss\" allowFullScreen=\"true\" allowScriptAccess=\"always\" width=\"480\" height=\"370\"></embed></object>");
		sinaVideoQueryVideoReg.setPlayTimesReg("<td width=\"57%\">播放次数：<span.*?>(.*?)</span> </td>");
		sinaVideoQueryVideoReg.setPlayUrlReg("<li class=\"bk1\"><a href=\"(.*?)\".*?><img.*?>.*?</li>");
		sinaVideoQueryVideoReg.setUploadDateReg("<td width=\"57%\">发布时间：(.*?)</td>");
		sinaVideoQueryVideoReg.setUploadUserIdReg("<li class=\"bk1\"><a href=\"http://you.video.sina.com.cn/b/[0-9]+\\-([0-9]+).html\" target=\"_blank\"><img.*?/></a></li>");
		sinaVideoQueryVideoReg.setUploadUsernameReg("<td width=\"43%\">播主：<a.*?>(.*?)</a></td>");
		sinaVideoQueryVideoReg.setUploadUserBlogUrlReg("<td width=\"43%\">播主：<a href=\"(.*?)\".*?>.*?</a></td>");
		sinaVideoQueryVideoReg.setUpdateUser("wangrui");
		sinaVideoQueryVideoReg.setUpdateDate(new Date());
		
		return sinaVideoQueryVideoReg;
	}
	
	public static VideoReg getSohuQueryPageVideoReg(SourceSite sohu) {
		VideoReg queryVideoReg = new VideoReg();
		queryVideoReg.setSourceSite(sohu);
		queryVideoReg.setPageCode("sohu_query_video_result");
		queryVideoReg.setPageName("搜狐搜索视频结果页");
		queryVideoReg.setPageEncoder("UTF-8");
		queryVideoReg.setPageMustTag("");
		queryVideoReg.setPageFrontFilterReg("");
		queryVideoReg.setPageBackFilterReg("");
		queryVideoReg.setVideoCountReg("\"data\": {\"hits\": .*?,\"count\": ([0-9]+),");
		queryVideoReg.setVideoPageCountReg("");
		queryVideoReg.setVideoListReg("\"list\": [(.*?)]");
		queryVideoReg.setVideoReg("{(.*?)})");

		queryVideoReg.setVideoId1Reg("\"id\": \"(.*?)\"");
		queryVideoReg.setVideoId2Reg("");
		queryVideoReg.setOriginalTitleReg("\"title\": \"(.*?)\"");
		queryVideoReg.setLogoReg("\"cusCoverURL\": \"(.*?)\"");
		queryVideoReg.setLengthReg("\"videoLength\": \"(.*?)\"");
		queryVideoReg.setCategoryReg("");
		queryVideoReg.setTagsReg("\"tag\": \"(.*?)\"");
		queryVideoReg.setSummaryReg("");
		queryVideoReg.setShareUrlReg("http://v.blog.sohu.com/fo/v4/::VIDEOID1");
		queryVideoReg.setObjectCodeReg("<object width=\"480\" height=\"389\"><param name=\"wmode\" value=\"transparent\" /><param name=\"movie\" value=\"::SHAREURL\" /><param name=\"allowFullScreen\" value=\"true\" /><embed src=\"::SHAREURL\" type=\"application/x-shockwave-flash\" width=\"480\" height=\"389\" allowFullScreen=\"true\"></embed></object>");
		queryVideoReg.setPlayTimesReg("\"playcount\": \"(.*?)\"");
		queryVideoReg.setPlayUrlReg("http://v.blog.sohu.com/u/vw/::VIDEOID1");
		queryVideoReg.setUploadDateReg("\"lastModified\": \"(.*?)\"");
		queryVideoReg.setUploadUserIdReg("\"userId\": \"(.*?)\"");
		queryVideoReg.setUploadUsernameReg("\"authorName\": \"(.*?)\"");
		queryVideoReg.setUploadUserBlogUrlReg("http://v.blog.sohu.com/u/us/::UPLOADUSERID");
		queryVideoReg.setUpdateUser("wangrui");
		queryVideoReg.setUpdateDate(new Date());
		
		return queryVideoReg;
	}
	
	public static VideoReg getWuliuQueryPageVideoReg(SourceSite wuliu) {
		VideoReg queryVideoReg = new VideoReg();
		queryVideoReg.setSourceSite(wuliu);
		queryVideoReg.setPageCode("56_query_video_result");
		queryVideoReg.setPageName("56搜索视频结果页");
		queryVideoReg.setPageEncoder("gb2312");
		queryVideoReg.setPageMustTag("<div id=\"search_new\">");
		queryVideoReg.setPageFrontFilterReg(".*<div id=\"result\">");
		queryVideoReg.setPageBackFilterReg("<div id=\"r\">.*");
		queryVideoReg.setVideoPageCountReg("");
		queryVideoReg.setVideoListReg("<div id=\"result\">(.*?)<div class=\"page\">");
		queryVideoReg.setVideoReg("<div class=\"find(.*?)</dl>.*?</div>");

		queryVideoReg.setVideoId1Reg("<div class=\"video\" >.*?<span id=s_(.*?)>");
		queryVideoReg.setVideoId2Reg("");
		queryVideoReg.setOriginalTitleReg("<dt><h3><a.*? title=\"(.*?)\">.*?</h3></dt>");
		queryVideoReg.setLogoReg("<div class=\"video\" >.*?<img src=\"(.*?)\".*?>");
		queryVideoReg.setLengthReg("<dd>时长：<span>(.*?)</span></dd>");
		queryVideoReg.setCategoryReg("");
		queryVideoReg.setTagsReg("");
		queryVideoReg.setSummaryReg("");
		queryVideoReg.setShareUrlReg("");
		queryVideoReg.setObjectCodeReg("");
		queryVideoReg.setPlayTimesReg("<dd>人气：<span class=\"playhot\">(.*?)</span></dd>");
		queryVideoReg.setPlayUrlReg("<dt><h3><a  href=\"(.*?)\".*?>.*?</h3></dt>");
		queryVideoReg.setUploadDateReg("<dd>发布：<span>(.*?)</span></dd>");
		queryVideoReg.setUploadUserIdReg("");
		queryVideoReg.setUploadUsernameReg("<dd>会员：<a.*?><u>(.*?)</u></a></dd>");
		queryVideoReg.setUploadUserBlogUrlReg("<dd>会员：<a href=\"(.*?)\".*?>.*?</a></dd>");
		queryVideoReg.setUpdateUser("wangrui");
		queryVideoReg.setUpdateDate(new Date());
		return queryVideoReg;
	}
	
	public static VideoReg getTudouQueryPageVideoReg(SourceSite tudou) {
		VideoReg queryVideoReg = new VideoReg();
		queryVideoReg.setSourceSite(tudou);
		queryVideoReg.setPageCode("tudou_query_video_result");
		queryVideoReg.setPageName("土豆搜索视频结果页");
		queryVideoReg.setPageEncoder("GBK");
		queryVideoReg.setPageMustTag("<div class=\"box search_result\">");
		queryVideoReg.setPageFrontFilterReg(".*<div class=\"box search_result\">");
		queryVideoReg.setPageBackFilterReg("<div class=\"side_col\">.*");
		queryVideoReg.setVideoCountReg("");
		queryVideoReg.setVideoPageCountReg("");
		queryVideoReg.setVideoListReg("<ul class=\"list list_2\">(.*?)</ul>");
		queryVideoReg.setVideoReg("<li class=\"item\">(.*?)</li>");
		queryVideoReg.setVideoId1Reg("<h6 class=\"caption\">.*?<a href=\"http://www.tudou.com/programs/view/(.*?)/\".*?>.*?</a>.*?</h6>");
		queryVideoReg.setVideoId2Reg("");
		queryVideoReg.setOriginalTitleReg("<h6 class=\"caption\">.*?<a.*?title=\"(.*?)\">.*?</a>.*?</h6>");
		queryVideoReg.setLogoReg("<div class=\"pic\">.*?<img src=\"(.*?)\".*?/>.*?</div>");
		queryVideoReg.setLengthReg("<h6 class=\"caption\">.*?<a.*?>.*?</a>.*?([0-9][0-9].*:[0-9][0-9]).*?</h6>");
		queryVideoReg.setQualityReg("<h6 class=\"caption\">.*?<img.*?title=\"(.*?)\" />.*?</h6>");
		queryVideoReg.setCategoryReg("");
		queryVideoReg.setTagsReg("");
		queryVideoReg.setSummaryReg("");
		queryVideoReg.setShareUrlReg("http://www.tudou.com/v/::VIDEOID1");
		queryVideoReg.setObjectCodeReg("<object width=\"400\" height=\"340\"><param name=\"movie\" value=\"::SHAREURL\"></param><param name=\"allowScriptAccess\" value=\"always\"></param><param name=\"wmode\" value=\"transparent\"></param><embed src=\"::SHAREURL\" type=\"application/x-shockwave-flash\" width=\"400\" height=\"340\" allowFullScreen=\"true\" wmode=\"transparent\" allowScriptAccess=\"always\"></embed></object>");
		queryVideoReg.setPlayTimesReg("<div class=\"info\">.*?播放.*?([0-9]*?)</div>");
		queryVideoReg.setPlayUrlReg("<h6 class=\"caption\">.*?<a href=\"(.*?)/\".*?>.*?</a>.*?</h6>");
		queryVideoReg.setUploadDateReg("<div class=\"info\">.*?上传于.*?([1-2][0-9][0-9][0-9]\\-[0-1][0-9]\\-[0-3][0-9]).*?</div>");
		queryVideoReg.setUploadUserIdReg("");
		queryVideoReg.setUploadUsernameReg("<div class=\"info\">.*?播客.*?<a.*?title=\"(.*?)\">.*?</a>.*?</div>");
		queryVideoReg.setUploadUserBlogUrlReg("<div class=\"info\">.*?播客.*?<a href=\"(.*?)\".*?>.*?</a>.*?</div>");
		queryVideoReg.setUpdateUser("wangrui");
		queryVideoReg.setUpdateDate(new Date());
		
		return queryVideoReg;
	}
	
	public static void main(String[] arg) {
		try {
			ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
			UniversalBo universalBo = (UniversalBo) applicationContext.getBean("universalBo");

			SourceSite youku = universalBo.getById(SourceSite.class, "youku");
			SourceSite tudou = universalBo.getById(SourceSite.class, "tudou");
			SourceSite sina = universalBo.getById(SourceSite.class, "sina");
			SourceSite ku6 = universalBo.getById(SourceSite.class, "ku6");
			SourceSite wuliu = universalBo.getById(SourceSite.class, "56");
			
			
			VideoReg re = getYoukuQueryPageVideoReg(youku);
			universalBo.doSave(re);
			
			re = getTudouQueryPageVideoReg(tudou);
			universalBo.doSave(re);
			
			re = getKuliuQueryPageVideoReg(ku6);
			universalBo.doSave(re);
			
			re = getSinaQueryPageVideoReg(sina);
			universalBo.doSave(re);
			
			re = getWuliuQueryPageVideoReg(wuliu);
			universalBo.doSave(re);
			
			/*
			SourceSite youku = inputMovieBo.getById(SourceSite.class, "youku");

			VideoReg youkuUserVideoReg = new VideoReg();
			youkuUserVideoReg.setSourceSite(youku);
			youkuUserVideoReg.setPageCode("YOUKU_USER_VIDEO_LIST");
			youkuUserVideoReg.setPageName("用户视频列表页");
			youkuUserVideoReg.setPageEncoder("UTF-8");
			youkuUserVideoReg.setPageMustTag("");
			youkuUserVideoReg.setPageFrontFilterReg("");
			youkuUserVideoReg.setPageBackFilterReg("");
			youkuUserVideoReg.setVideoPageCountReg("<a href=\"/user_video/id_.*?_order_1_type_2_page_([0-9]+).html\" title='末页'>末页</a>");
			youkuUserVideoReg.setVideoListReg("<div class=\"vList\">(.*?)</div><!--vList end-->");
			youkuUserVideoReg.setVideoReg("<ul class=\"video\">(.*?)</ul>");

			youkuUserVideoReg.setVideoId1Reg("<li class=\"videoImg\"><a.*?><img.*?name=\"(.*?)\".*?/></a></li>");
			youkuUserVideoReg.setVideoId2Reg("");
			youkuUserVideoReg.setOriginalTitleReg("<li><h1>.*?<a.*?title=\"(.*?)\".*?>.*?</a>.*?</h1></li>");
			youkuUserVideoReg.setLogoReg("<li class=\"videoImg\"><a.*?><img.*?src=\"(.*?)\".*?/></a></li>");
			youkuUserVideoReg.setLengthReg("<li><h1>.*?<a.*?>.*?</a>.*?<span class=\"num\">(.*?)</span>.*?</h1></li>");
			youkuUserVideoReg.setCategoryReg("");
			youkuUserVideoReg.setTagsReg("");
			youkuUserVideoReg.setSummaryReg("");
			youkuUserVideoReg.setShareUrlReg("");
			youkuUserVideoReg.setObjectCodeReg("");
			youkuUserVideoReg.setPlayTimesReg("<span class=\"f2nd\">播放:</span> <span class=\"num\">(.*?)</span>");
			youkuUserVideoReg.setPlayUrlReg("<li class=\"videoImg\"><a href=\"(.*?)\".*?>.*?</a></li>");
			youkuUserVideoReg.setUploadDateReg("<span class=\"f2nd\">发布:</span> <span class=\"num\">(.*?)</span>");
			youkuUserVideoReg.setUploadUserIdReg("<a class=\"fNav\" href=\"http://u.youku.com/user_show/id_(.*?)\\.html\">首页</a>");
			youkuUserVideoReg.setUploadUsernameReg("<title>(.*?)的优酷视频空间.*?</title>");
			youkuUserVideoReg.setUploadUserBlogUrlReg("<a class=\"fNav\" href=\"(.*?)\">首页</a>");
			youkuUserVideoReg.setUpdateUser("wangrui");
			youkuUserVideoReg.setUpdateDate(new Date());

			//inputMovieBo.doSave(youkuUserVideoReg);
			VideoReg videoReg2 = new VideoReg();
			videoReg2.setSourceSite(youku);
			videoReg2.setPageCode("YOUKU_VIDEO_PLAY");
			videoReg2.setPageName("视频播放页");
			videoReg2.setPageEncoder("UTF-8");
			videoReg2.setPageMustTag("");
			videoReg2.setPageFrontFilterReg("");
			videoReg2.setPageBackFilterReg("");
			videoReg2.setVideoListReg("(.*)");
			videoReg2.setVideoReg("(.*)");
			videoReg2.setVideoId1Reg("<script type=\"text/javascript\">.*?var videoId2= '(.*?)';.*?</script>");
			videoReg2.setVideoId2Reg("<script type=\"text/javascript\">.*?var videoId = '([0-9+])';.*?</script>");
			videoReg2.setOriginalTitleReg("<meta name=\"title\" content=\"(.*?)\">");
			videoReg2.setLogoReg("");
			videoReg2.setLengthReg("");
			videoReg2.setCategoryReg("<ul class=\"videoInfo\" id=\"detail\" style=\"display:none\">.*?<li>.*?分类.*?<div class=\"f_l\">.*?<a.*?>(.*?)</a>.*?</div>.*?</li>");
			videoReg2.setTagsReg("<meta name=\"keywords\" content=\"(.*?)\">");
			videoReg2.setSummaryReg("<ul class=\"videoInfo\" id=\"detail\" style=\"display:none\">.*?<li>(.*?)</li>");
			videoReg2.setShareUrlReg("<ul class=\"pasteLink\">.*?<li><span class=\"label\">flash地址:</span> <input type=\"text\" id=\"link\" value=\"(.*?)\" />.*?</li>.*?</ul>");
			videoReg2.setObjectCodeReg("<ul class=\"pasteLink\">.*?<li><span class=\"label\">html代码:</span> <input  id=\"link3\" type=\"text\" value='(.*?)' />.*?</li>.*?</ul>");
			videoReg2.setPlayUrlReg("");
			videoReg2.setPlayTimesReg("<ul class=\"videoInfo\" id=\"detail\" style=\"display:none\">.*?<li.*?>.*?播放.*?<span class=\"num\">(.*?)</span>.*?</li>");
			videoReg2.setUploadDateReg("");
			videoReg2.setUploadUserIdReg("");
			videoReg2.setUploadUsernameReg("");
			videoReg2.setUploadUserBlogUrlReg("");
			videoReg2.setUpdateUser("wangrui");
			videoReg2.setUpdateDate(new Date());
			
			
			//inputMovieBo.doSave(videoReg2);
			

			SourceSite tudou = inputMovieBo.getById(SourceSite.class, "tudou");
			
			VideoReg tuDouUserVideoReg = new VideoReg();
			tuDouUserVideoReg.setSourceSite(tudou);
			tuDouUserVideoReg.setPageCode("TUDOU_USER_VIDEO_LIST");
			tuDouUserVideoReg.setPageName("土豆用户视频列表页");
			tuDouUserVideoReg.setPageEncoder("GBK");
			tuDouUserVideoReg.setPageMustTag("");
			tuDouUserVideoReg.setPageFrontFilterReg(".*<div class=\"main\">");
			tuDouUserVideoReg.setPageBackFilterReg("</div><!-- end main-->.*");
			tuDouUserVideoReg.setVideoPageCountReg("<li><a.*?>([0-9]+?)</a></li> <li class='pagebarNext'><a.*?>.*?</a></li></ul>");
			tuDouUserVideoReg.setVideoListReg("<div class=\"box m m_border clips\">(.*?)<div class=\"nav pagebar fix\"><ul>");
			tuDouUserVideoReg.setVideoReg("<div class=\"pack pack_clip\">[^<]*?<div class=\"wide\"><div class=\"in\">(.*?)</ul>[^<]*?</div>");

			tuDouUserVideoReg.setVideoId1Reg("<li>视频：<a href=\"/programs/view/([^/]*?)/\" target=\"new\">.*?</a></li>");
			tuDouUserVideoReg.setVideoId2Reg("");
			tuDouUserVideoReg.setOriginalTitleReg("<li>视频：<a.*?>(.*?)</a></li>");
			tuDouUserVideoReg.setLogoReg("<img src=\"(.*?)\" class=\"pack_clipImg\" />");
			tuDouUserVideoReg.setLengthReg("");
			tuDouUserVideoReg.setCategoryReg("");
			tuDouUserVideoReg.setTagsReg("");
			tuDouUserVideoReg.setSummaryReg("");
			tuDouUserVideoReg.setShareUrlReg("");
			tuDouUserVideoReg.setObjectCodeReg("");
			tuDouUserVideoReg.setPlayTimesReg("<li>播放：<b>(.*?)</b>.*?</li>");
			tuDouUserVideoReg.setPlayUrlReg("<li>视频：<a href=\"(.*?)\" target=\"new\">.*?</a></li>");
			tuDouUserVideoReg.setUploadDateReg("<li>时间：<b>(.*?)</b></li>");

			tuDouUserVideoReg.setUploadUserIdReg("");
			tuDouUserVideoReg.setUploadUsernameReg("<div class=\"header m\">.*?<h1>(.*?)的个人主页</h1>");
			tuDouUserVideoReg.setUploadUserBlogUrlReg("<a href=\"(.*?)\" class=\"homeurl\">.*?</a>");

			tuDouUserVideoReg.setUpdateUser("wangrui");
			tuDouUserVideoReg.setUpdateDate(new Date());

			//inputMovieBo.doSave(tuDouUserVideoReg);
			
			tuDouUserVideoReg = inputMovieBo.getById(VideoReg.class, 2L);
			tuDouUserVideoReg.setVideoPageCountReg("<li><a.*?>([0-9]+?)</a></li> <li class='pagebarNext'><a.*?>.*?</a></li></ul>");
			//inputMovieBo.doUpdate(tuDouUserVideoReg);
			
			
			
			//inputMovieBo.doDelete(VideoReg.class, 3L);

			videoReg2 = new VideoReg();
			videoReg2.setSourceSite(tudou);
			videoReg2.setPageCode("TUDOU_VIDEO_PLAY");
			videoReg2.setPageName("视频播放页");
			videoReg2.setPageEncoder("GBK");
			videoReg2.setPageMustTag("");
			videoReg2.setPageFrontFilterReg("");
			videoReg2.setPageBackFilterReg("");
			videoReg2.setVideoListReg("(.*)");
			videoReg2.setVideoReg("(.*)");
			videoReg2.setVideoId1Reg("<script type=\"text/javascript\">.*?iid_code = '(.*?)'.*?</script>");
			videoReg2.setVideoId2Reg("<script type=\"text/javascript\">.*?var iid = ([0-9]+).*?</script>");
			videoReg2.setOriginalTitleReg("<title>(.*?) \\- 视频 \\- 在线观看 \\- 土豆网</title>");
			videoReg2.setLogoReg("");
			videoReg2.setLengthReg("");
			videoReg2.setCategoryReg("");
			videoReg2.setTagsReg("<script type=\"text/javascript\">.*?kw = \"(.*?)\".*?</script>");
			videoReg2.setSummaryReg("<div id=\"memos\">(.*?)</div>");

			videoReg2.setShareUrlReg("http://www.tudou.com/v/::VIDEOID1");
			videoReg2.setObjectCodeReg("<object width=\"400\" height=\"340\"><param name=\"movie\" value=\"::SHAREURL\"></param><param name=\"allowScriptAccess\" value=\"always\"></param><param name=\"wmode\" value=\"transparent\"></param><embed src=\"::SHAREURL\" type=\"application/x-shockwave-flash\" width=\"400\" height=\"340\" allowFullScreen=\"true\" wmode=\"transparent\" allowScriptAccess=\"always\"></embed></object>");

			videoReg2.setPlayUrlReg("http://www.tudou.com/programs/view/::VIDEOID1/");
			videoReg2.setPlayTimesReg(".*?该视频被播放：<b class=\"playNum\">(.*?)</b>");
			videoReg2.setUploadDateReg("<li class=\"publishTime\">发布于: (.*?)</li>");
			videoReg2.setUploadUserIdReg("<a class=\"button subscribe\" onclick=\"TUI.api.subscribe('podcast', '([0-9]+?)');return false;\" href=\"#\"><i>订阅视频</i></a>");
			videoReg2.setUploadUsernameReg("<div class=\"author_info\">\\s<ul>\\s<li class=\"author_name fix\"><a href=\"/home/.*?\".*?>(.*?)</a>");
			videoReg2.setUploadUserBlogUrlReg("<div class=\"author_info\">\\s<ul>\\s<li class=\"author_name fix\"><a href=\"(.*?)\".*?>.*?</a>");
			videoReg2.setUpdateUser("wangrui");
			videoReg2.setUpdateDate(new Date());


			//inputMovieBo.doMerge(videoReg2);
			
			videoReg2 = inputMovieBo.getById(VideoReg.class, 3L);
			videoReg2.setVideoId1Reg("<script type=\"text/javascript\">.*?iid_code = '(.*?)'.*?</script>");
			videoReg2.setVideoId2Reg("<script type=\"text/javascript\">.*?var iid = ([0-9]+).*?</script>");
			inputMovieBo.doUpdate(videoReg2);
			*/
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
}
